home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / text / hyper / ADtoHT2_1.lha / Source.lha / MyLib.lha / string / strrchr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-05  |  521 b   |  43 lines

  1. #include <string.h>
  2.  
  3. /************************************************************************/
  4.  
  5. #undef strrchr
  6.  
  7. #if defined(__GNUC__) && defined(mc68000)
  8.  
  9. asm("
  10.     .globl    _strrchr
  11. _strrchr:
  12.     movel    sp@(4:W),a1
  13.     movel    sp@(8:W),d1
  14.     moveq    #0,d0
  15. L2:    cmpb    a1@,d1
  16.     jne    L1
  17.     movel    a1,d0
  18. L1:    tstb    a1@+
  19.     jne    L2
  20.     rts
  21. ");
  22.  
  23. #else
  24.  
  25. char *strrchr(const char *String, int c)
  26.  
  27. {
  28.   char *Result;
  29.  
  30.   Result=NULL;
  31.   do
  32.     {
  33.       if(*String==(char)c)
  34.     {
  35.       Result=(char *)String;
  36.     }
  37.     }
  38.   while(*String++!='\0');
  39.   return Result;
  40. }
  41.  
  42. #endif
  43.